package top.codehelen.api.controller;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.codehelen.common.response.R;
import top.codehelen.service.UsersService;
/**
 * @Classname PasswordController
 * @Description  登录controller
 * @Date 2021/5/15 2:18 PM
 * @Created by helen
 */
@RestController
@RequestMapping("/passport")
@Slf4j
public class PasswordController {

    @Autowired
    private UsersService usersService;

    @GetMapping("/userNameIsExist")
    public R userNameIsExist(@RequestParam String userName) {

        if(StrUtil.isBlank(userName)) {
            return R.failedWithArgument("请输入用户名");
        }

        boolean b = usersService.selectUserNameIsExist(userName);
        if (b) {
            return R.success();
        }
        return R.failedWithArgument("用户不存在");
    }
}
